package mapViewer;

import context.*;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import mapViewer.screens.AccountScreen;
import mapViewer.screens.SplashScreen;

// ********************************************************************
// *** CLASS: MapViewer
// ********************************************************************
/**
* Map Viewer application for MIDP 2.0
*/
public class MapViewer extends MIDlet implements Debug.Constants
{ //private static final boolean DEBUG=true; // Overriding Debug.Constants.DEBUG

  private MapNavigator mapNavigator;

  
  public MapViewer()
  { Context.setMidlet(this);
//  Context.setDisplay(Display.getDisplay(this));
	try { new AccountRecordStore(); }
    catch(Exception e) { Debug.EXCEPTION("MapViewer: ",e); }
  }
  
  public void showAccountScreen()
  { new AccountScreen(this).show(); }

  // ******************************************************************
  // *** METHOD: startApp
  // ******************************************************************
  /**
  * Signals the MIDlet to start and enter the Active state.
  */
  protected void startApp()
  { if(DEBUG) Debug.println("MapViewer.startApp: Application started");
    Context.setCurrent(new SplashScreen(this));
  }
  
  public void connect()
  { if(DEBUG) Debug.println("MapViewer.connect:");  
    mapNavigator=new MapNavigator();
    Context.setCurrent(mapNavigator);
  }
  
  // ******************************************************************
  // *** METHOD: pauseApp
  // ******************************************************************
  /**
  * Signals the MIDlet to stop and enter the Paused state.
  */
  protected void pauseApp()
  {
    // we need to implement this since it is abstract in the MIDlet
  }
  
  // ******************************************************************
  // *** METHOD: destroyApp
  // ******************************************************************
  /**
  * Signals the MIDlet to terminate and enter the Destroyed state.
  */
  protected void destroyApp(boolean unconditional)
  { // notify the application management that it has entered into the
    // Destroyed state, all resources held by the MIDlet will be considered
    // eligible for reclamation.
    // Performe clean-up operations here (releasing of resources etc.)
    Context.exit();
  }

}